// 字符串去重 
function uniq(arr1) {
    var arr2 = [];
    (arr1.split('')).forEach(function (item) {
        if (arr2.indexOf(item) == -1) {
            arr2.push(item);
        }
    });
    return (arr2.join(''));
}
console.log(uniq('122222222222'));


// 实现冒泡排序：
function Sort(arr) {
    for (var i = 0; i < arr.length - 1; i++) {
        for (var j = 0; j < arr.length - 1 - i; j++) {
            if (arr[j] > arr[j + 1]) {
                var temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
    return arr;
}
var arr1 = [6, 5, 4, 3, 2, 1];
console.log(Sort(arr1));
// // 数组去重求和
// console.log('2222');
function getSum(arr) {
    var num = 0;
    var newArr = [];
    for (var i = 0; i < arr.length; i++) {
        if (typeof (arr[i]) == 'number') {
            if (newArr.indexOf(arr[i]) == -1) {
                newArr.push(arr[i]);
            }
        }
    }
    for (var j = 0; j < newArr.length; j++) {
        num += newArr[j];
    }
    return num;
}
console.log(getSum([undefined, "23year", 19, "097", 1, "hello", null, 1]));
